package com.example.understandvideo.pojo;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;

public class JsonConverter {

    private final ObjectMapper objectMapper = new ObjectMapper();

    public Request convertJsonToRequest(String jsonString) throws Exception {
        return objectMapper.readValue(jsonString, Request.class);
    }

    public static void main(String[] args) {
        JsonConverter converter = new JsonConverter();
        String jsonString = "{\"model\":\"doubao-1.5-vision-pro-250328\",\"messages\":[{\"content\":[{\"text\":\"图片主要讲了什么?\",\"type\":\"text\"},{\"image_url\":{\"url\":\"data:image/<图片格式>;base64,\"},\"type\":\"image_url\"}],\"role\":\"user\"}]}";

        try {
            Gson gson = new Gson();
            Request request = gson.fromJson(jsonString, Request.class);
            System.out.println(request);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
